package boerse.main.StockPriceProvider;

import boerse.main.Asset.Share;
import boerse.main.Exceptions.NegativeValueException;

import java.util.TimerTask;

/**
 * Change the share price for ramdom value between -12 and 12
 * @author Domi
 *
 */
public class RandomStockPriceProvider extends StockPriceProvider {

    private double max = 12;
    private double min = -12;

    public RandomStockPriceProvider() {
        super();
        startUpdate();
    }

    @Override
    protected void updateShareRate(Share share) {
        long price = share.getPrice();
        double x = Math.random()*(max-min+1)+min;
        try {
            share.setPrice(price + (long) x);
        } catch (NegativeValueException e) {
            return;
        }
    }
}
